<template>
  <view>
    <div class="box">
      <div class="inform">
        <div class="row" v-for="item in data" :key="item.id">
          <div class="col">
            <div class="label">{{ item.name }}</div>
            <t-textarea @input="item.isChange = true" v-model="item.remark" placeholder="请输入内容" />
            <t-button theme="primary" @click="onSubmit(item)" style="margin-right: 10px" v-if="item.isChange"
              >保存</t-button
            >
            <div class="tag">前端通知数据，注意不要有空行</div>
          </div>
        </div>
      </div>
      <!-- <div class="btnBox">
        <t-button theme="primary" size="large">立即提交</t-button>
        <t-button variant="outline" theme="default" size="large">重置</t-button>
      </div> -->
    </div>
  </view>
</template>
<script setup lang="ts">
import { getLangList, edit } from '@/api/system/basicSetting/7';
import { ref } from 'vue';
import { MessagePlugin } from 'tdesign-vue-next';
const data = ref([]);
const unGetUserList = async () => {
  try {
    const res = await getLangList({
      pageNum: 1,
      pageSize: 999,
      status: '1',
    });
    data.value = res.rows;
  } catch (e) {
    console.log(e);
  }
};

unGetUserList();

const emit = defineEmits(['handleClickDelete']);
// 提交
const form = ref({
  isChange: false,
});
const onSubmit = (item: any) => {
  form.value = item;
  emit('handleClickDelete');
};
const submit = async () => {
  try {
    const res = await edit(form.value);
    if (res.code === 200) {
      form.value.isChange = false;
      MessagePlugin.success('提交成功');
    }
  } catch (error) {
    console.log(error);
  }
};

defineExpose({
  submit,
});
</script>
<style lang="less" scoped>
.box {
  padding: 10px;

  .row {
    display: flex;
    padding: 25px 0;

    &:nth-child(2n) {
      // background-color: #f2f2f2;
    }

    .col {
      flex: 1;
      display: flex;
      align-items: center;
      flex-wrap: wrap;

      .label {
        width: 110px;
        font-size: 12px;
        text-align: right;
        word-wrap: break-word;
        word-break: break-word;
        color: #666;
      }

      .tag {
        min-width: 110px;
        font-size: 12px;
        color: #999;
      }
    }
  }

  .btnBox {
    display: flex;
    justify-content: center;
  }
}
</style>

<style class="less">
.col {
  .t-input__wrap {
    width: 240px;
    margin: 0 10px;

    & .t-input {
      height: 38px;
      font-size: 12px;
    }
  }

  .t-select__wrap {
    width: 240px;

    .t-select-input {
      width: 240px;
      height: 38px;
      font-size: 12px;
    }
  }

  .t-radio-group {
    margin: 0 10px;
  }

  .t-textarea {
    width: 400px;
    margin: 0 10px;

    .t-textarea__inner {
      width: 400px;
      font-size: 12px;
    }
  }

  .t-input-number.t-input-number--row {
    width: 240px;
    display: flex;
    align-items: center;
    padding: 0 38px;
    margin: 0 10px;

    .t-button.t-button--variant-outline.t-button--theme-default.t-button--shape-square.t-button--icon-only {
      width: 38px;
      height: 38px;
    }

    .t-input__wrap {
      min-width: 156px;
    }
  }
}

.inform .col {
  .t-textarea {
    width: 62.5rem;

    .t-textarea__inner {
      width: 62.5rem;
    }
  }
}
</style>
